package com.lyrcsoft.autoconfigure;

import com.lyrcsoft.annotation.LyrcsoftConditionOnClass;
import com.lyrcsoft.impl.JettyWebServer;
import com.lyrcsoft.impl.TomcatWebServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * Web容器注入Spring 自动配置
 *
 * @author fujc-dev@qq.com
 * @date: 2023年11月01日 13:16
 */
@Configuration
public class WebServerAutoConfiguration {

    /**
     * 项目中有Tomcat依赖生效
     *
     * @return
     */
    @Bean
    //@Conditional(TomcatCondition.class)
    @LyrcsoftConditionOnClass("org.apache.catalina.startup.Tomcat")
    public TomcatWebServer tomcatWebServer() {
        return new TomcatWebServer();
    }

    /**
     * 项目中有Jetty依赖生效
     *
     * @return
     */
    @Bean
    //@Conditional(JettyCondition.class)
    @LyrcsoftConditionOnClass("org.eclipse.jetty.server.Server")
    public JettyWebServer jettyWebServer() {
        return new JettyWebServer();
    }
}
